package com.example.demospringretry.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.retry.RetryListener;
import org.springframework.retry.annotation.EnableRetry;
import org.springframework.retry.stats.DefaultStatisticsRepository;
import org.springframework.retry.stats.StatisticsListener;

@EnableRetry
@Configuration
@EnableConfigurationProperties(BizRetryProperties.class)
public class DemoConfiguration {

    @Autowired
    private BizRetryProperties bizRetryProperties;

    @Bean
    RetryListener statisticsListener() {
        return new StatisticsListener(new DefaultStatisticsRepository());
    }
}
